package com.controller;

import com.dao.TalkKiaraDao;
import com.entity.ResponseMessage;
import com.entity.TalkKiara;
import com.service.TalkKiaraService;
import com.service.TalkKiaraServiceImpl;
import org.springframework.beans.BeanUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.web.bind.annotation.*;
import org.thymeleaf.util.ObjectUtils;

import javax.annotation.Resource;
import java.util.ArrayList;
import java.util.List;

/**
 * @author WZ
 * @version 1.0
 * @date 2021/10/1 14:55
 */
@RestController
@CrossOrigin
public class KiaraController {
     @Autowired
	 private TalkKiaraService talkKiaraService;
     @Resource
	TalkKiaraDao talkKiaraDao;
	@RequestMapping("randomKiara")
	public ResponseMessage randomKiara(){
		TalkKiara talkKiara=talkKiaraService.randomKiara();
		ResponseMessage responseMessage=new ResponseMessage();
		if(talkKiara!=null){
			responseMessage.setCode(ResponseMessage.SUCCESS);
			responseMessage.setMsg("成功");
			responseMessage.setData(talkKiara);
		}else {
			responseMessage.setCode(ResponseMessage.FAIL);
			responseMessage.setMsg("异常");
			responseMessage.setData(null);
		}


          return responseMessage;
	}

	@RequestMapping("testids")
	public ResponseMessage testIds(@RequestParam("ids") List<Integer> ids){

		return new ResponseMessage(ResponseMessage.SUCCESS,"success",talkKiaraDao.test1(ids));
	}

}
